﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="News_List.aspx.cs" validateRequest="false"  Inherits="ncp.Web.cms.News_List" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="../../themes/icon.css" />
    <link href="../../css/base.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="../../js/jquery-1.7.1.min.js"></script>
	<script type="text/javascript" src="../../js/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../../../js/common.js"></script>
</head>
<body style="margin:0; padding:0px;">
    <form id="form1" runat="server">
        <div class="toolbar" style="background-color:#efefef">
            <a id="divA" href="#" class="easyui-linkbutton" plain="true" iconCls="icon-ok" onclick="onReleaseGoods();">发布新闻图片</a>
        </div>
        <div id="divright">    
        </div>
	    <div class="previewbox">
	        <span title="关闭" onclick="hidePreview()" class="imgdelete"></span>
	        <img  src=""/>
	    </div>
	</form>
</body>
</html>
<%--商品信息--%>
<script type="text/javascript">

    $(function() {
        initDatagrid();
        LoadNewsInfo();
    });

    //初始化表格
    function initDatagrid() {
        $('#divright').datagrid({
            height: $(window).height() - 61,
            nowrap: true,
            striped: true,
            singleSelect: true,
            sortName: 'News_Date',
            sortOrder: 'desc',
            remoteSort: false,
            idField: 'News_Id',
            pagination: false,
            rownumbers: true,
            columns: [[
					{ field: 'News_Id', title: '文章编号', hidden: 'true', width: 80 },
					{ field: 'News_Title', title: '文章标题', sortable: 'true', width: 360 },
					{ field: 'News_Picture', title: '缩略图', sortable: 'false', width: 40, align: 'center',
					    formatter: function(val, rec) {
					        if (val != "") {
					            return "<img class=\"imgPreview\" onclick=\"imgPreView(this)\" src=\"/cms/images/pic.png\" title=\"预览\" titleimg=\"" + val + "\" style=\"cursor: pointer\">";
					        } else {
					            return "无";
					        }
					    }
					},
					{ field: 'News_Flag', title: '自定义属性', sortable: 'false', width: 100,
					    formatter: function(val, rec) {
					    var str = "<span style=\"color:red;\">";
					        if (val!=null) {
					            if (val.indexOf('h') != -1) {
					                str += "[头条]";
					            }
					            if (val.indexOf('c') != -1) {
					                str += "[推荐]";
					            }
					            if (val.indexOf('f') != -1) {
					                str += "[幻灯]";
					            }
					            if (val.indexOf('a') != -1) {
					                str += "[特荐]";
					            }
					        }
					        str += "</span>";
					        return str;
					    }
					},
					{ field: 'News_Date', title: '更新时间', sortable: 'true', width: 130 },
					{ field: 'NC_Name', title: '文章类别', sortable: 'true', width: 80, align: 'center' },
					{ field: 'News_times', title: '点击', sortable: 'true', width: 60, align: 'center' },
					{ field: 'User_Account', title: '发布人', sortable: 'true', width: 60, align: 'center' },
					{ field: 'News_Status', title: '状态', sortable: 'true', width: 60, align: 'center',
					    styler: function(value, row, index) {
					        if (value == '0') {
					            return 'color:red;font-weight:bold;';
					        }
					    },
					    formatter: function(val, rec) {
					        if (val == '0') {
					            return "禁用";
					        } else {
					        return "启用";
					        }
					    }
					}
				]]
        });
    }

    function imgPreView(dom) {
        $(dom).click(function(e) {
            $(".previewbox img").attr("src", $(dom).attr("titleimg"));
            $(".previewbox").css({ "top": e.pageY+10, "left": e.pageX-200 });
            $(".previewbox").fadeIn();
        });
    }
    
    function hidePreview() {
        $('.previewbox').fadeOut();
    }

    //装载新闻信息视图
    function LoadNewsInfo() {
        var response = ncp.Web.cms.News_List.BindTable();
        if (response.value != null) {
            var data = eval(response.value);
            $('#divright').datagrid('loadData', data);
        }
    }

    //发布新闻信息
    function onReleaseGoods() {
        if (confirm("您确定要发布吗？")) {
            var response = ncp.Web.cms.News_List.ReleaseNews();
            if (response.value != null) {
                var jsonOBJ = eval(response.value)[0];
                if (jsonOBJ.isreload) {
                    LoadNewsInfo();
                }
                alert(jsonOBJ.msg);
            }
        }
        return false;
    }
</script>
